import { IndexModel } from '../models'
import '../scss/common.scss'

class App {
  constructor (options) {
    this.swiper = options.swiper;
    this.phone = options.phone;
    this.field = options.field;
    this.cache = null;
    this.$app = $('<div id="app">');
    this.init();
  }
  async init () {
    await this.getDatas();
    this.render();
  }
  async getDatas () {
    const indexModel = new IndexModel();
    const data = await indexModel.getDatas({
      swiper: this.swiper,
      phone: this.phone,
      field: this.field
    })

    this.cache = {
      phoneDatas: data.phone_data || null,
      filedDatas: data.field_data || null,
      swiperDatas: data.swiper_data || null
    }
    // await indexModel.getDatas({
    //   swiper: this.swiper,
    //   phone: this.phone,
    //   field: this.field
    // }).then((res) => {
    //   this.cache = {
    //     phoneDatas: res.phone_data,
    //     filedDatas: res.field_data,
    //     swiperDatas: res.swiper_data
    //   }
    // })
  }
}
export { App }